<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Prototype Unit test file</title>
  <meta http-equiv="content-type" content="text/html; charset=utf-8" />
  <script src="../../vendor/prototype.js" type="text/javascript"></script>
  <script src="../lib/unittest.js" type="text/javascript"></script>
  <script src="../../dist/inheritance.js" type="text/javascript" charset="utf-8"></script>
  <link rel="stylesheet" href="../test.css" type="text/css" />
  <style type="text/css" media="screen">
  /* <![CDATA[ */
    #testcss1 { font-size:11px; color: #f00; }
    #testcss2 { font-size:12px; color: #0f0; display: none; }
  /* ]]> */
  </style>
</head>
<body>
<h1>Inheritance Unit test file</h1>
<p>
  Test inheritance features of inheritance.js
</p>

<!-- Log output -->
<div id="testlog"> </div>

<!-- Tests follow -->
<script type="text/javascript" language="javascript" charset="utf-8">
// <![CDATA[

  // -- define a classes
  
  Person = Class.extend({
    initialize: function(name) {
      this.name = name;
    },

    toString: function() {
      return this.name;
    }
  });

  // -- some place holder variables
  
  var joe;
  var sue;
  var bill;

  // -- begin unit tests

  new Test.Unit.Runner({

    teardown: function() {
      joe = null;
      sue = null;
      bill = null;
    },
    
    testFunctionExists: function() { with (this) {
      assert(typeof(Person) == 'function');
    }},

    testPrototypeExists: function() { with(this) {
      // test code here
      assertNotNull(Person.prototype);
    }},
    
    testInstantiation: function() { with(this) {
      assertNull(joe);
      
      joe = new Person();
      
      assertNotNull(joe);
    }},
    
    testConstructorExists: function() { with(this) {
      joe = new Person();
      
      assertRespondsTo("initialize", joe);
    }},
    
    testConstructorWithParams: function() { with(this) {
      joe = new Person("Joe");
      
      assertEqual("Joe", joe.name);
    }},
    
    testToStringExists: function() { with(this) {
      joe = new Person();
      assertRespondsTo("toString", joe);
    }},
    
    testToStringResponse: function() { with(this) {
      joe = new Person("Joe");
      assertEqual("Joe", joe.toString());
    }},
    
    testNoExtraPropertiesInPrototype: function() { with(this) {
      var count = 0;
      
      for (var prop in Person.prototype) {
        count++
      }
      // initialize and toString
      assertEqual(2, count);      
    }},
    
    testNoExtraPropertiesInInstance: function() { with(this) {
      var count = 0;
      // make sure an instance only contains defined methods and properties
      joe = new Person("Joe");
      for (var prop in joe) {
        count++;
      }
      
      // initialize, toString and this.name
      assert(3, count);
    }}

  }, 'testlog');
// ]]>
</script>
</body>
</html>